package Presentation;

import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.Plot;
import org.jfree.chart.plot.PiePlot;
import org.jfree.data.general.PieDataset;
import org.jfree.data.general.DefaultPieDataset;

import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.OutputStream;
import java.io.IOException;
import java.io.File;

public class GraphBuilder {

    public static void main(String[] args) {
        DefaultPieDataset pds = new DefaultPieDataset();
        pds.setValue("a",1);
        pds.setValue("b",2);
        pds.setValue("c",3);
        Plot p = new PiePlot(pds);
        JFreeChart jf = new JFreeChart("g",p);
        BufferedImage i = jf.createBufferedImage(200,200);
        // Write generated image to a file
        try {
            // Save as PNG
            File file = new File("newimage.png");
            ImageIO.write(i, "png", file);
    
            // Save as JPEG
            file = new File("newimage.jpg");
            ImageIO.write(i, "jpg", file);
        } catch (IOException e) {
        }

    }



}
